<template>
  <div class="container-fuild">
    <div class="row page-titles">
      <ol class="breadcrumb">
        <li class="breadcrumb-item active">专家管理 /</li>
        <li class="breadcrumb-item">专家管理</li>
      </ol>
    </div>
    <div class="row">
      <div class="card">
        <div class="card-header">
          <p class="card-title">专家信息</p>
        </div>
        <div class="card-body custom-ekeditor">
          <div id="ckeditor">
            <template>
              <el-table :data="tableData" style="width: 100%; color: #7d94c0">
                <el-table-column
                  prop="expertName"
                  label="姓名"
                  width="100"
                ></el-table-column>
                <el-table-column
                  prop="phone"
                  label="手机号"
                  width="120"
                ></el-table-column>
                <el-table-column
                  prop="gender"
                  label="性别"
                  width="80"
                ></el-table-column>
                <el-table-column
                  prop="unit"
                  label="单位"
                  width="80"
                ></el-table-column>
                <el-table-column
                  prop="title"
                  label="职称"
                  width="100"
                ></el-table-column>
                <el-table-column
                  prop="email"
                  label="邮箱"
                  width="120"
                ></el-table-column>
                <el-table-column
                  label="操作"
                  style="margin-left: 100px; text-align: center"
              
                >
                  <template slot-scope="scope">
                    <el-button
                      type="text"
                      size="mini"
                      style="
                        background-color: steelblue;
                        color: white;
                        width: 70px;
                      "
                      @click="dialogFormVisible = true"
                      >添加
                    </el-button>
                    <el-button
                      type="text"
                      size="mini"
                      style="
                        background-color: steelblue;
                        color: white;
                        width: 70px;
                      "
                      @click="dele(scope.row)"
                      >删除
                    </el-button>
                    <el-button
                      type="text"
                      size="mini"
                      style="
                        background-color: steelblue;
                        color: white;
                        width: 70px;
                      "
                      @click="dialogFormVisible2 = true"
                      >实训过程
                    </el-button>
                    <el-dialog
                      title="专家信息"
                      :visible.sync="dialogFormVisible"
                      style="font-weight: bold"
                      append-to-body
                      width="70%"
                      class="showAll_dialog"
                    >
                      <el-form :model="form">
                        <el-form-item
                          label="姓名"
                          :label-width="formLabelWidth"
                        >
                          <el-input
                            v-model="form.expertName"
                            autocomplete="off"
                          ></el-input>
                        </el-form-item>
                        <el-form-item
                          label="电话"
                          :label-width="formLabelWidth"
                        >
                          <el-input
                            v-model="form.phone"
                            autocomplete="off"
                          ></el-input>
                        </el-form-item>
                        <el-form-item
                          label="职称"
                          :label-width="formLabelWidth"
                        >
                          <el-input
                            v-model="form.title"
                            autocomplete="off"
                          ></el-input>
                        </el-form-item>
                        <el-form-item
                          label="邮件"
                          :label-width="formLabelWidth"
                        >
                          <el-input
                            v-model="form.email"
                            autocomplete="off"
                          ></el-input>
                        </el-form-item>
                        <el-form-item
                          label="性别"
                          :label-width="formLabelWidth"
                        >
                          <el-input
                            v-model="form.gender"
                            autocomplete="off"
                          ></el-input>
                        </el-form-item>
                        <el-form-item
                          label="单位"
                          :label-width="formLabelWidth"
                        >
                          <el-input
                            v-model="form.unit"
                            autocomplete="off"
                          ></el-input>
                        </el-form-item>
                      </el-form>
                      <div slot="footer" class="dialog-footer">
                        <el-button @click="dialogFormVisible = false"
                          >取 消</el-button
                        >
                        <el-button
                          type="primary"
                          @click="onSubmit"
                          >确 定</el-button
                        >
                      </div>
                    </el-dialog>
                    <el-dialog
                      title="评分信息"
                      :visible.sync="dialogFormVisible2"
                      style="font-weight: bold"
                      append-to-body
                      width="70%"
                      class="showAll_dialog"
                    >
                    <el-form :model="form2">
                        <el-form-item
                          label="实训班"
                          :label-width="formLabelWidth"
                        >
                          <el-select style="margin-left:20px;width:500px;" v-model="form2.className" placeholder="请选择">
                        <el-option
                          v-for="item in options1.data"
                          :key="item"
                          :label="item"
                          :value="item"
                        >
                        </el-option>
                      </el-select>
                        </el-form-item>
                        <el-form-item
                          label="实训小组"
                          :label-width="formLabelWidth"
                        >
                          <el-select style="margin-left:20px;width:500px;" v-model="form2.groupName" placeholder="请选择">
                        <el-option
                          v-for="item in options2.data"
                          :key="item"
                          :label="item"
                          :value="item"
                        >
                        </el-option>
                      </el-select>
                        </el-form-item>
                        <el-form-item
                          label="数学与专业基础评分"
                          :label-width="formLabelWidth2"
                        >
                          <el-input
                            v-model="form2.expertpanel_rating_1"
                            autocomplete="off"
                            style="margin-left:0px;width:120px;"
                          ></el-input>
                        </el-form-item>
                        <el-form-item
                          label="实验设计评分"
                          :label-width="formLabelWidth2"
                        >
                          <el-input
                            v-model="form2.expertpanel_rating_2"
                            autocomplete="off"
                            style="margin-left:0px;width:120px;"
                          ></el-input>
                        </el-form-item>
                        <el-form-item
                          label="工具使用评分"
                          :label-width="formLabelWidth2"
                        >
                          <el-input
                            v-model="form2.expertpanel_rating_3"
                            autocomplete="off"
                            style="margin-left:0px;width:120px;"
                          ></el-input>
                        </el-form-item>
                        <el-form-item
                          label="设计算法评分"
                          :label-width="formLabelWidth2"
                        >
                          <el-input
                            v-model="form2.expertpanel_rating_4"
                            autocomplete="off"
                            style="margin-left:0px;width:120px;"
                          ></el-input>
                        </el-form-item>
                        <el-form-item
                          label="项目与团队合作评分"
                          :label-width="formLabelWidth2"
                        >
                          <el-input
                            v-model="form2.expertpanel_rating_5"
                            autocomplete="off"
                            style="margin-left:0px;width:120px;"
                          ></el-input>
                        </el-form-item>
                        <el-form-item
                          label="解决复杂问题评分"
                          :label-width="formLabelWidth2"
                        >
                          <el-input
                            v-model="form2.expertpanel_rating_6"
                            autocomplete="off"
                            style="margin-left:0px;width:120px;"
                          ></el-input>
                        </el-form-item>
                        <el-form-item
                          label="技术前沿评分"
                          :label-width="formLabelWidth2"
                        >
                          <el-input
                            v-model="form2.expertpanel_rating_7"
                            autocomplete="off"
                            style="margin-left:0px;width:120px;"
                          ></el-input>
                        </el-form-item>
                        <el-form-item
                          label="职业伦理评分"
                          :label-width="formLabelWidth2"
                        >
                          <el-input
                            v-model="form2.expertpanel_rating_8"
                            autocomplete="off"
                            style="margin-left:0px;width:120px;"
                          ></el-input>
                        </el-form-item>
                      </el-form>
                      <div slot="footer" class="dialog-footer">
                        <el-button @click="dialogFormVisible2 = false"
                          >取 消</el-button
                        >
                        <el-button
                          type="primary"
                          @click="onSubmit2"
                          >确 定</el-button
                        >
                      </div>
                    </el-dialog>
                  </template>
                </el-table-column>
              </el-table>
            </template>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: "Addclassteacher",
  data() {
    return {
      tableData: [],
      dialogFormVisible: false,
      dialogFormVisible2: false,
      form: {
        expertName: "",
        phone: "",
        title: "",
        email: "",
        gender: "",
        unit: "",
      },
      form2:{
        className:"",
        groupName:"",
        expertpanel_rating_1:"",
        expertpanel_rating_2:"",
        expertpanel_rating_3:"",
        expertpanel_rating_4:"",
        expertpanel_rating_5:"",
        expertpanel_rating_6:"",
        expertpanel_rating_7:"",
        expertpanel_rating_8:"",
      },
      options1:[],
      options2:[],
      formLabelWidth: "120px",
      formLabelWidth2:"140px"
    
    };
  },
  mounted(){
    this.classNameShow();
    this.groupNameShow();
    this.expertShow();
  },

  methods: {
    onSubmit() {
      // console.log(this.form);
      this.$axios.post("http://localhost:9090/user/addExpert", this.form).then(alert("成功，请刷新界面"))
    },
    onSubmit2(){
      // console.log(this.form2);
      this.$axios.post("http://localhost:9090/ExpertpanelScoresImport", this.form2).then(alert("成功，请刷新界面"))
    },
    classNameShow: function () {
      let _this = this;
      this.$axios.get('http://localhost:9090/user/getTrainClass')
          .then(function (res) {
            _this.options1 = res.data;
            console.log(_this.options1);
            // console.log(res);
          })
          .catch(function (err) {
            // console.log(err);
          });
    },
    groupNameShow: function () {
      let _this = this;
      this.$axios.get('http://localhost:9090/user/getGroupName')
          .then(function (res) {
            _this.options2 = res.data;
            // console.log(_this.options2);
            // console.log(res);
          })
          .catch(function (err) {
            // console.log(err);
          });
    },
    expertShow: function () {
      let _this = this;
      this.$axios.get('http://localhost:9090/user/getExpert')
          .then(function (res) {
            _this.tableData = res.data.data;
            // console.log(_this.tableData);
            // console.log(res);
          })
          .catch(function (err) {
            // console.log(err);
          });
    },
    dele(e){
      // alert(JSON.stringify(e))
      // alert(e.phone)
      this.$axios.post("http://localhost:9090/user/deleteExpert",{phone:e.phone}).then(alert("成功，请刷新界面"));
    }

  },
};
</script>

<style scoped>
/*表头*/
.container-fuild {
  float: left;
  /*padding-top:1.875rem;*/
  padding-right: 1.875rem;
  padding-left: 1.875rem;
  width: 93%;
  margin-right: auto;
  margin-left: auto;
  font-size: 0.875rem;
  font-weight: 400;
  line-height: 1.5;
  color: #7d94c0;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
}

.page-titles {
  justify-content: space-between;
  /*padding: 0.1375rem 0.5rem;*/
  padding-top: 0.25rem;
  padding-right: 1.875rem;
  padding-bottom: 0.25rem;
  padding-left: 1.875rem;
  background: #fff;
  margin-bottom: 1.875rem;
  border-radius: 1rem;
  margin-top: 0;
  margin-left: 0;
  margin-right: 0;
  --bs-gutter-x: 30px;
  --bs-gutter-y: 0;
  display: flex;
  flex-wrap: wrap;
}

.page-titles .breadcrumb {
  margin-bottom: 0;
  padding: 0;
  background: transparent;
  font-size: 1.1875rem;
  display: flex;
  flex-wrap: wrap;
  padding: 0 0;
  margin-bottom: 1rem;
  list-style: none;
  flex-shrink: 0;
  width: 100%;
  max-width: 100%;
}

.breadcrumb li.active {
  font-weight: 600;
  font-size: 1.1875rem;
}

.breadcrumb li {
  margin-top: 0;
  margin-bottom: 0;
  padding-left: 0.5rem;
  font-size: 1.1875rem;
}

/*主题部分*/
.row {
  --bs-gutter-x: 30px;
  --bs-gutter-y: 0;
  display: flex;
  flex-wrap: wrap;
  margin-top: calc(var(--bs-gutter-y) * -1);
  margin-right: calc(var(--bs-gutter-x) / -2);
  margin-left: calc(var(--bs-gutter-x) / -2);
}

.card {
  width: 100%;
  margin-bottom: 1.875rem;
  background-color: #fff;
  transition: all 0.5s ease-in-out;
  position: relative;
  border: 0rem solid transparent;
  border-radius: 1.25rem;
  box-shadow: 0rem 0.3125rem 0.3125rem 0rem rgb(82 63 105 / 5%);
  height: calc(100% - 30px);

  display: flex;
  flex-direction: column;
  min-width: 0;
  word-wrap: break-word;
  background-color: #fff;
  background-clip: border-box;
}

.card-header {
  border-color: #f5f5f5;
  position: relative;
  background: transparent;
  padding-top: 0rem;
  padding-right: 1.875rem;
  padding-bottom: 0rem;
  padding-left: 1.875rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.card-title {
  padding-top: 0.5rem;
  padding-bottom: 0.5rem;
  font-size: 1.1rem;
  font-weight: 300;
  color: #909399;
  text-transform: capitalize;
}

.card-body {
  padding-top: 0.125rem;
  padding-right: 1.875rem;
  padding-bottom: 1.125rem;
  padding-left: 1.875rem;

  flex-grow: 1;
  flex-shrink: 1;
  flex-basis: auto;
}

.table-responsive-md {
  min-width: 36rem !important;
}

/*弹窗*/
.el-table .warning-row {
  background: oldlace;
}

.el-table .success-row {
  background: #f0f9eb;
}

/*让dialog能够悬浮在中间*/
.showAll_dialog {
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: auto;
}

::v-deep .el-dialog {
  margin: 0 auto !important;
  height: 80%;
  overflow: auto;
  background-color: white;
}

.el-dialog__body {
  position: absolute;
  left: 0;
  top: 54px;
  bottom: 0;
  right: 0;
  z-index: 1;
  overflow: hidden;
  overflow-y: auto;

  line-height: 30px;
  padding: 15px;
}

/*弹窗标题的padding*/
::v-deep .el-dialog__header {
  padding-top: 20px;
  padding-right: 50px;
  padding-bottom: 10px;
  padding-left: 50px;
}
/*弹窗标题的padding*/
::v-deep .el-dialog__header {
  padding-top: 30px;
  padding-right: 50px;
  padding-bottom: 30px;
  padding-left: 50px;
}

/*弹窗标题的颜色*/
::v-deep .el-dialog__title {
  color: #909399;
}

/*弹窗尾部按钮颜色*/
.el-button--primary {
  color: #fff;
  background-color: #016bb7;
  border-color: #016bb7;
}

::v-deep .el-button {
  border-radius: 5px;
}
</style>